using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using OneSoft.EntityCore;
using OneSoft.DataAccess;
using BySoft.Server.Common.Entity;
using BySoft.Server.Common.Schema;
using BySoft.Server.Common;

namespace BySoft.Server.DataAccess
{
    public partial class MdMachineDA
    {


        private static string GetHeadSQL()
        {
            return @"SELECT A.*,sp.ParameterName AS MachineTypeName
                    FROM MD_Machine A  LEFT  JOIN SYS_Parameter AS sp  ON a.MachineType=sp.ParameterCode 
                       AND sp.ParameterTypeID='MachineType'
                       
                    WHERE 1=1";
        }
        public static DataTable SelectList(string MachineID, string MachineName,string strMachineTypeCode, int pageIndex, int PageSize, out int m_count)
        {
            try
            {
                #region SQL Server
                string strcmd = GetHeadSQL();

                DataAccessParameterCollection dpc = new DataAccessParameterCollection();

                if (!string.IsNullOrEmpty(MachineID))
                {
                    strcmd += " and MachineID LIKE @MachineID";
                    dpc.AddWithValue("@MachineID", "%" + MachineID + "%");
                }

                if (!string.IsNullOrEmpty(MachineName))
                {
                    strcmd += " and MachineName LIKE @MachineName";
                    dpc.AddWithValue("@MachineName", "%" + MachineName + "%");
                }
                if (!string.IsNullOrEmpty(strMachineTypeCode))
                {
                    strcmd += " and MachineType = @MachineType";
                    dpc.AddWithValue("@MachineType", strMachineTypeCode);
                }
                strcmd += " ORDER BY MachineID DESC";
                return DataAccessCommon.ExecuteDataTablePaging(strcmd, pageIndex, PageSize, dpc, out m_count);
                #endregion
            }
            catch
            {
                throw;
            }
        }


     
       
    }
}

